package com.example.module_word.room;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.fenghuajueli.libbasecoreui.BaseApplication;

@Database(entities = {Hearing.class},version = 1,exportSchema = false)
public abstract class HearingDataBase extends RoomDatabase {
    private static final String DB_NAME = "hearing.db";
    private static volatile HearingDataBase instance;
    public static synchronized HearingDataBase getInstance() {
        if (instance == null) {
            instance = create();
        }
        return instance;
    }

    private static HearingDataBase create() {
        return Room.databaseBuilder(
                BaseApplication.getApplication(),
                HearingDataBase.class,
                DB_NAME)
                .createFromAsset("yuedu.db")//从assets复制
                .allowMainThreadQueries()//允许在主线程允许
                .build();
    }
    public abstract HearingDao getHearingDao();
}
